package com.efresh.nico.gr_superman.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

import com.efresh.nico.gr_superman.R;
import com.efresh.nico.gr_superman.dao.Mission;

import java.util.List;

/**
 * Created by admin on 2015/12/6.
 */
public class MymissionAdapter  extends ArrayAdapter<Mission>{
    private int resourceId ;
    public MymissionAdapter(Context context, int resource,List<Mission> objects) {
        super(context, resource,objects);
        resourceId = resource ;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        Mission mission = getItem(position);
        View view ;
        ViewHolder viewHolder ;
        if(convertView == null){
            view = LayoutInflater.from(getContext()).inflate(resourceId, null);
            viewHolder = new ViewHolder();
            viewHolder.aim_address = (TextView) view.findViewById(R.id.text_aim_address_id);
            viewHolder.get_address = (TextView) view.findViewById(R.id.text_get_address_id);
            viewHolder.pay_time = (TextView) view.findViewById(R.id.text_pay_time_id);
            view.setTag(viewHolder);
        }else{
            view = convertView ;
            viewHolder = (ViewHolder) view.getTag();
        }
        viewHolder.aim_address.setText(mission.getAim_address());
        viewHolder.get_address.setText(mission.getWhouse());
        viewHolder.pay_time.setText(mission.getPay_time());   //setText()参数不能为int类型
//
        return view;
    }
    class ViewHolder{
        TextView aim_address ;
        TextView get_address ;
        TextView pay_time ;
    }
}
